[VAULT-21456] Add a drop in replacement for the Go regexp package that interns regular expressions#156
Merged
[VAULT-21456] Add a drop in replacement for the Go regexp package that interns regular expressions#156
Conversation
…ing of pattern compilation
…ptures finalization of the Regexps to clear the maps
…tle to later authors where used
bosouza
reviewed
Feb 19, 2025
bosouza
reviewed
Feb 19, 2025
bosouza
left a comment
There was a problem hiding this comment.
This looks great, the weak package fits like a glove! I'm so glad we could avoid unsafe/reflection :D
…ile, so that the tests for it are run in CI
… what stdlib version to use with this module
…ng issues, fix returns in compile and mustComplile, edit a comment
raskchanky
reviewed
Feb 20, 2025
raskchanky
left a comment
There was a problem hiding this comment.
Generally looks great! I left a few comments.
As I was reading through this, I thought maybe this was a good use case for https://pkg.go.dev/unique which was introduced in go 1.23. On the surface, it seems like exactly what the unique package was made for. The principal downside to that approach is the pointers aren't weak, so you would end up with a map of regexes that sticks around indefinitely.
… map passed in as an argument and the reverseMap; clean up some comments
…lete entries from either the POSIX or non-POSIX map, rather than both
…SIX and non-POSIX regexs
Contributor
|
Can you add a description to this PR for posterity? |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
regexpmodule, which interns regular expressions to avoid excessive memory use.The new module uses Go's
weakpackage, so it requires at least Go 1.24 to work.